﻿using System.Windows.Forms;
using System.Data;
using SystemCustomers.DBUtils;
using SystemCustomers.MessageUtils;

namespace SystemCustomers.ManageProject
{
    class ManageViewingAllProject
    {
        public static string Id { get; set;}

        public DataTable InitializeProject()
        {
            return SingletonManagerDb.Instance.DbViewingProject();
        }

        public DialogResult EditProject(DataGridViewRow dr)
        {
            using (var project = new AddProject(dr.Cells["projectName"].Value.ToString(), dr.Cells["projectDescription"].Value.ToString()))
            {
                Id = dr.Cells["idProject"].Value.ToString();
                project.btnAdd.Visible = false;
                var result = project.ShowDialog();
                if (result == DialogResult.Cancel) return result;
                else
                {
                    LogUtils.WriteToLog(" Edit Row Viewing All Project: " + dr.Cells["projectName"].Value.ToString());
                    LogUtils.SystemEventLogsInformation(" Edit Row Viewing All Project: " + dr.Cells["projectName"].Value.ToString());
                    return result;
                }
            }
        }

        public void DeleteProject(DataGridViewRow dr)
        {
            Id = dr.Cells["idProject"].Value.ToString();
            SingletonManagerDb.Instance.DeleteProjectRow(Id);
            LogUtils.WriteToLog(" Delete Row Viewing All Project: " + dr.Cells["projectName"].Value.ToString());
            LogUtils.SystemEventLogsInformation(" Delete Row Viewing All Project: " + dr.Cells["projectName"].Value.ToString());
        }
    }
         
}
